#include<bits/stdc++.h>
using namespace std;
const int NN=1e5+4;
int a[NN],up[NN];
bool flag;
vector<int>g[NN];
void dfs(int u,int fa)
{
    if(g[u].size()==1)
    {
        up[u]=a[u];
        return;
    }
    long long res=0;
    int maxv=0;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(v==fa)
            continue;
        dfs(v,u);
        res+=up[v];
        maxv=max(maxv,up[v]);
    }
    if(max(1ll*maxv,res/2+res%2)>a[u]||res<a[u])
        flag=false;
    up[u]=a[u]-(res-a[u]);
}
int main()
{
    freopen("clean.in","r",stdin);
    freopen("clean.out","w",stdout);
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            g[i].clear();
        }
        for(int i=1;i<n;i++)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            g[u].push_back(v);
            g[v].push_back(u);
        }
        if(n==1)
            puts(!a[1]?"YES":"NO");
        else if(n==2)
            puts(a[1]==a[2]?"YES":"NO");
        else
        {
            flag=true;
            int root=1;
            for(int i=2;i<=n;i++)
                if(g[i].size()>=2)
                    root=i;
            dfs(root,0);
            puts(flag&&!up[root]?"YES":"NO");
        }
    }
    return 0;
}